/*******************************************************************************
 * 文件名: DataImportFactory.java
 * 描    述: 数据导入工厂类
 * 创建人: Dean Huang(hudi-112@163.com)
 * 日　期: 2017-12-22
 * 描　述: 文件描述
 * 版　本: 1.0
 *******************************************************************************/

package com.z1.core.data.imports;

import java.io.File;

import com.z1.core.data.DataConfig;
import com.z1.core.data.imports.csv.CsvImport;
import com.z1.core.data.imports.excel.ExcelImport;
import com.z1.core.exception.Z1Exception;

public final class DataImportFactory {

	public static DataImport parse(DataConfig dataConfig, File f, boolean containHeader) {
		String fileName = f.getName();
		String suffix = fileName.substring(fileName.lastIndexOf("."));
		switch (suffix) {
		case ".xls" : 
		case ".xlsx":
			return ExcelImport.parse(dataConfig, f, containHeader);
		case ".csv" :
			return CsvImport.parse(dataConfig, f, containHeader);
		default :
			throw new Z1Exception("仅支持处理Excel、Csv文件.");
		}
	}
	
}
